package com.TT.ticket.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest1 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //new Thread(new MyThread()).start();
        //new Thread(new Runnable()).start();
        //new Thread(new FutureTask<>()).start();
        //new Thread(new FutureTask<>( Callable )).start();

        //怎么启动Callable
        MyThread thread = new MyThread();
        FutureTask futureTask = new FutureTask(thread);
        new Thread(futureTask,"A").start();

        String o = (String) futureTask.get();  //获取结果
        System.out.println(o);
    }

}
/*class MyThread implements Runnable {

    @Override
    public void run() {

    }
}*/
class MyThread implements Callable<String> {

    @Override
    public String call() throws Exception {
        return "8686887";
    }
}
